Release 10.1A: OpenEdge Development:
Programming Interfaces
How errors are handled when STRICT is TRUE
If
STRICTis set toTRUE, then the writer will validate the structure of the XML document as it writes it out. With this attribute, the SAX-writer attempts to keep the developer from creating invalid XML documents. It does this by ensuring that the methods are called in correct order.If it finds an incorrect method call then:
Table 21–3: Common error messages Methods effected DescriptionIf a particular method is called when the
WRITE-STATUSattribute status value is an illegal value for the method, the method will fail and generate an error message.See "Errors raised by invalid method calls during SAX-writer states" section.
If the root tag has not been closed and
END-DOCUMENTis called, the method fails and generates the following message:
END-DOCUMENT attempted to close the document before the root tag was closed.You must close the root tag with
END-ELEMENTbefore closing the documentIf
FRAGMENTisFALSE, then there may be only one root node, that is, the document-level node. If a call to one of these methods would result in a second document-level node then the following error message is generated:
<method> attempted to create a second a document level node in the document.You must limit each XML document to one document-level node.END-ELEMENTFor each
START-ELEMENTcall, you must have a corresponding and matchingEND-ELEMENTcall. Start and end all nodes to properly form parent and child relationships. All nodes must be started and ended (excluding empty nodes). IfEND-ELEMENTis called with the incorrect name/prefix then it will fail and generate the message:
END-ELEMENT attempted to close the tag <qname> when the current tag to close was <qname>.Do not interweave different start and end tags,WRITE-CHARACTERSOnly call
WRITE-CHARACTERSfrom within the document. That is, call it from within the root node. If it is called at the document level, it will fail and generate the following error:
WRITE-CHARACTERS attempted to write character data at the document level.INSERT-ATTRIBUTEDECLARE-NAMESPACEAttribute names must be unique. If a call to either of these methods results in a repeated instance of a name, then the methods fail and the following error message will be generated:
<method> attempted to create a second instance of the name <name>.Also, these methods can only be called when the
WRITE-STATUSisSAX-WRITE-TAGor they fail and generate an error message as describe in "Errors raised by invalid method calls during SAX-writer states" section.For example:
hSAXWriter:STRICT = TRUE. hSAXWriter:START-DOCUMENT(). hSAXWriter:START-ELEMENT("root",""). hSAXWriter:START-ELEMENT("name",""). hSAXWriter:WRITE-CHARACTER("Alex Herbstritt", 16). hSAXWriter:END-ELEMENT("root",""). /* method fails */ hSAXWriter:END-DOCUMENT().This code fragment would generate an error because “root” was closed before “name”.
The following conditions generate an error message when
STRICTis set toTRUE:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |